package com.woniuxy.carlife.carlifeuserweb.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.woniuxy.carlife.carlifecommonsweb.exception.CarlifeGlobalException;
import com.woniuxy.carlife.carlifeuserweb.entity.Caryears;
import com.woniuxy.carlife.carlifeuserweb.mapper.CaryearsMapper;
import com.woniuxy.carlife.carlifeuserweb.service.CaryearsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zjq
 * @ClassName:CaryearsServiceImpl
 * @Description:查询汽车年份
 * @date 2021/4/6 20:02
 **/

@Service
public class CaryearsServiceImpl extends ServiceImpl<CaryearsMapper, Caryears> implements CaryearsService {


    @Resource
    CaryearsMapper caryearsMapper;

    /*
     * 功能描述〈查询所有汽车年份〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/11 22:27
     * @throws
     */

    @Override
    public List<Caryears> findCaryears()  {
        QueryWrapper<Caryears> caryearsQueryWrapper = new QueryWrapper<>();
        List<Caryears> caryears = caryearsMapper.selectList(caryearsQueryWrapper);
        return caryears == null ? null : caryears;
    }


    /*
     * 功能描述〈根据汽车年份id查询〉
     * @author:zjq
     * @param:
     * @return:
     * @Date 2021/4/11 22:27
     * @throws
     */

    @Override
    public Caryears findCaryearsById(String cardisplacementId)  {
        QueryWrapper<Caryears> caryearsQueryWrapper = new QueryWrapper<>();
        caryearsQueryWrapper.eq("caryears_id", cardisplacementId);
        Caryears caryears = caryearsMapper.selectOne(caryearsQueryWrapper);
        return caryears == null ? null : caryears;
    }
}
